from rest_framework.viewsets import GenericViewSet

from apps.models import ErrorLog
from apps.serializers.Log import ErrorLogSerializer
from apps.utils.common_response import APIResponse


class ErrorLogView(GenericViewSet):
    def list(self,request):
        #  获取所有错误日志
        logs = ErrorLog.objects.all().order_by('-log_time')
        # 序列化并返回
        serializer = ErrorLogSerializer(logs,many=True)
        return APIResponse(msg='错误日志查询成功',data=serializer.data)
